<template>
  <el-dialog title="公司信息填写" :visible.sync="dialogFormVisible" :before-close="close" width="1045px" top="2vh">
    <div class="add_companyWrapp">
    <el-form
    :rules="rules"
    :inline="true"
    :model="addcompanyForm"
    status-icon
    ref="addcompanyForm"
    label-width="130px"
    label-position="right"
    class="addCompanyForm">
      <el-form-item label="公司名称：" class="formItemType" prop="companyname">
        <el-input type="text" v-model="addcompanyForm.companyname" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="管理员手机号：" class="formItemType" prop="ctUsermobile">
        <el-input type="number" v-model="addcompanyForm.ctUsermobile" auto-complete="off" max="11" class="formItemInput"></el-input>
        <span style="font-size: 12px;position: absolute;top: 30px;right: 2px;color: #409eff;">管理员用户名默认为"admin"</span>
      </el-form-item>
      <el-form-item label="公司电话："  class="formItemType">
        <el-input type="number" v-model="addcompanyForm.cpyTel" auto-complete="off" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="省县区域：" class="formItemType">
        <el-cascader :style=""clearable :options="CityInfo" v-model="cityData" change-on-select class="formItemInput"></el-cascader>
      </el-form-item>
 <!--      <el-form-item label="通讯地址：" class="formItemType">
        <el-input v-model="addcompanyForm.comaddress" class="formItemInput"></el-input>
      </el-form-item> -->
      <el-form-item label="详细地址：" class="formItemType">
        <el-input v-model="addcompanyForm.dtladdress" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="成立日期：" class="formItemType">
        <el-date-picker
          v-model="addcompanyForm.cpyDate"
          type="date"
          format="yyyy-MM-dd"
          placeholder="选择日期"
          :picker-options="pickerOptions"
          value-format="yyyy-MM-dd HH:mm:ss"
          class="formItemInput">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="公司法人：" class="formItemType">
        <el-input v-model="addcompanyForm.cpyMgruser" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="法人電話：" class="formItemType">
        <el-input v-model="addcompanyForm.cpyMgrmobile" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="公司证件号：" class="formItemType">
        <el-input v-model="addcompanyForm.cpyDutyno" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="优先级排序："   class="formItemType">
        <el-input type="number" v-model="addcompanyForm.orderindex" auto-complete="off" class="formItemInput"></el-input>
      </el-form-item>
      <el-form-item label="公司行业性质：" class="formItemType">
        <el-select v-model="addcompanyForm.cpyNature" clearable placeholder="请选择" class="formItemInput">
        <el-option
          v-for="item in NatureOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
      </el-form-item>

<!-- 
      <el-form-item label="公司简介："  class="cpyRemark">
        <el-input type="textarea" :rows="5" v-model="addcompanyForm.cpyRemark" class="textareaBox"></el-input>
      </el-form-item> -->

      <el-form-item label="公司Logo：" class="block">
          <singleUpload :params="uploadLogo" :uploadSuccess="logoSuccess" :width="145" :height="145"></singleUpload>
      </el-form-item>

      <el-form-item label="附件信息：" class="block">
          <imgUpload :params="uploadFile" :uploadSuccess="uploadSuccess" :uploadRemove="uploadRemove"></imgUpload>
      </el-form-item>

    </el-form>
    <div slot="footer" class="add_dialog_footer">
      <el-button  @click="close">取 消</el-button>
      <el-button type="primary"  @click="submitForm">确 定</el-button>
    </div>
  </div>
  </el-dialog>
</template>

<script>
import {getProvincial}   from '../../../../common/js/provincial'
import imgUpload         from '@/components/img-upload/imgUpload'
import singleUpload      from '@/components/img-upload/singleUpload'
export default {
  props:["dialogFormVisible","addCompanyForm","addSubmit"],
  data(){
    return{
      rules:{
        companyname:[
            { required: true, message: '公司名称不能为空', trigger: 'blur' }
        ],
        ctUsermobile:[
            { required: true, message: '请输入手机号', trigger: 'blur' }
        ]
      },
      addcompanyForm: {
        orderindex:100
      },
      cityData:[],
      picArray:[],
      CityInfo:getProvincial(),
      NatureOptions: [{
       value: '国有企业',
       label: '国有企业'
      },{
       value: '集体企业',
       label: '集体企业'
     }, {
       value: '私营企业',
       label: '私营企业'
     },{
         value: '股份有限公司',
         label: '股份有限公司'
       }],
       uploadFile:{
         name:"cpmparyFile"
       },
       uploadLogo:{
         name:"cpmparyLogoFile"
       },
       pickerOptions:{
           //設置選擇時間不可大於以後的時間
           disabledDate(time) {
            return time.getTime() > Date.now();
           }
       }
    }
  },
  created(){
     // console.log(this.$store.getters.UserInfo);
     // this.addcompanyForm= this.addCompanyForm;
  },
  methods:{
    logoSuccess(val){
      this.addcompanyForm.cpyLogo = val;
    },
    uploadSuccess(val){
       this.addcompanyForm.cpyUpfiles = val.toString();
    },
    uploadRemove(val){
       this.addcompanyForm.cpyUpfiles = val.toString();
    },
    submitForm(){
      this.addcompanyForm.cityname = this.cityData.toString();
      this.$refs['addcompanyForm'].validate((valid) => {
         if (valid) {
          // let params = {
          //   orderindex:100,
          //   departmentid:this.$store.getters.UserInfo.departmentId,
          //   disenable:this.$store.getters.UserInfo.disEnable,
          //   ismanager:this.$store.getters.UserInfo.ismanager,
          //   mobile:this.$store.getters.UserInfo.mobile,
          //   registerflag:this.$store.getters.UserInfo.registerFlag,
          //   sex:this.$store.getters.UserInfo.sex,
          //   uid:this.$store.getters.UserInfo.uid,
          //   userid:this.$store.getters.UserInfo.userId,
          //   username:this.$store.getters.UserInfo.userName,
          //   usertype:this.$store.getters.UserInfo.userType,
          //   workstate:this.$store.getters.UserInfo.workState,
          //   entrydate:this.$store.getters.UserInfo.entryDate
          // }
          // this.addcompanyForm.userInfoQos = params;
          this.addSubmit(this.addcompanyForm);
          this.$emit('update:dialogFormVisible', false)
         }else{
             this.$message.error("必填项不能为空");
         }
      })
    },
    close(){
      this.$emit('update:dialogFormVisible', false)
    }
  },
  components:{
    imgUpload,
    singleUpload
  }
}
</script>
<style scoped>
.add_companyWrapp{
  text-align: left;
  padding: 20px 0;
}
.formItemType{
  width: 48%;
}
.formItemInput{
  width:285px;
}
.cpyRemark{
  display: block;
}
.textareaBox{
  width: 778px;
}
.block{
  display: block;
}
.add_dialog_footer{
  text-align: right;
}
</style>
